package builder.simple;

public class Student {
	private String name;
	private int number;
	private String sex;
	private int age;
	private String school;

	public Student(StudentBuilder builder) {
		this.age = builder.age;
		this.name = builder.name;
		this.number = builder.number;
		this.school = builder.school;
		this.sex = builder.sex;
	}

	@Override
	public String toString() {
		return "Student [name=" + name + ", number=" + number + ", sex=" + sex + ", age=" + age + ", school=" + school
				+ "]";
	}

	public static class StudentBuilder {

		private String name = null;
		private int number = -1;
		private String sex = null;
		private int age = -1;
		private String school = null;

		public StudentBuilder setName(String name) {
			this.name = name;
			return this;
		}

		public StudentBuilder setNumber(int number) {
			this.number = number;
			return this;
		}

		public StudentBuilder setSex(String sex) {
			this.sex = sex;
			return this;
		}

		public StudentBuilder setAge(int age) {
			this.age = age;
			return this;
		}

		public StudentBuilder setSchool(String school) {
			this.school = school;
			return this;
		}

		public Student build() {
			return new Student(this);
		}
	}

}
